package com.kefu.dto;

import lombok.Data;

@Data
public class ResultDTO<T> {
    private int code;              // 0-成功，1-失败
    private String message;
    private T data;

    // 成功响应
    public static <T> ResultDTO<T> success(T data) {
        ResultDTO<T> result = new ResultDTO<>();
        result.setCode(0);
        result.setMessage("操作成功");
        result.setData(data);
        return result;
    }

    // 失败响应
    public static <T> ResultDTO<T> fail(String message) {
        ResultDTO<T> result = new ResultDTO<>();
        result.setCode(1);
        result.setMessage(message);
        result.setData(null);
        return result;
    }
}
